using System;
using System.Linq;
using NUnit.Framework;

namespace TDDGettingStarted.DryRun.DomainLayer.Repositories
{
   public interface IInventoryRepository
   {
      InventoryWeek GetInventoryWeek(int facilityNumber, DateTime weekEndDate);
   }

   public class InventoryRepositoryStub : IInventoryRepository
   {
      public InventoryWeek GetInventoryWeek(int facilityNumber, DateTime weekEndDate)
      {
         return new InventoryWeek {FacilityNumber = facilityNumber, WeekEndDate = weekEndDate};
      }
   }

   namespace InventorySystemDesignHelper
   {
      [TestFixture]
      public class RetrievingInventoryWeeks
      {
         private int _facilityNumber = -99;
         private readonly DateTime _weekEndDate = DateTime.Parse("6/14/2008");

         [Test]
         public void GetInventoryWeekTest()
         {
            InventoryWeek inventoryWeek = CreateSUT().GetInventoryWeek(_facilityNumber, _weekEndDate);
            Assert.IsNotNull(inventoryWeek);
            Assert.AreEqual(_facilityNumber, inventoryWeek.FacilityNumber);
            Assert.AreEqual(_weekEndDate, inventoryWeek.WeekEndDate);
         }

         [Test]
         public void GetInventoryWeekReturnsWithFacilityInventoryTest()
         {
            var inventoryWeek = CreateSUT().GetInventoryWeek(_facilityNumber, _weekEndDate);
            Assert.IsTrue(inventoryWeek.FacilityInventory.Count() > 0);
         }

         private IInventoryRepository CreateSUT()
         {
            return new InventoryRepositoryStub();
         }
      }
   }
}